package z.explorer.ui.common;

import java.util.List;

import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.TableRowSorter;


public class ZTable extends JTable {

	private static final long serialVersionUID = -3155733763196331895L;
	
	private TableRowSorter<ZTableModel> sorter=null;
	
	private ZTableModel zTableModel = null;
	
	private boolean editable = true;
	
	public ZTable(ZTableModel model) {
		super(model);
		zTableModel = model;
		sorter = new TableRowSorter<ZTableModel>(zTableModel);
		setRowSorter(sorter);

	}
	
	public ZTable(ZTableModel model,boolean editable){
		this(model);
		this.editable = editable;
	}
	
	public ZTable(List list){
		zTableModel = new ZTableModel(list);
		setModel(zTableModel);
		sorter = new TableRowSorter<ZTableModel>(zTableModel);
		setRowSorter(sorter);
	}
	
	public ZTable(List list, boolean editable){
		this(list);
		this.editable = editable;
	}
	
	public TableRowSorter<ZTableModel> getSorter(){
		return sorter;
	}
	
	public void setSorter(TableRowSorter<ZTableModel> s){
		sorter=s;
		setRowSorter(sorter);
	}
	
	public void reloadData(List list){
		zTableModel.reloadData(list);
	}

	@Override
	public boolean isCellEditable(int row, int column) {
		// TODO Auto-generated method stub
		return editable;
	}

	public boolean isEditable() {
		return editable;
	}

	public void setEditable(boolean editable) {
		this.editable = editable;
	}

	public ZTableModel getzTableModel() {
		return zTableModel;
	}
		
}
